using APITransLib.Contracts;
using ChatWithMulitAIServer.Data;
using Microsoft.AspNetCore.Mvc;

namespace ChatWithMulitAIServer.Controllers;

[ApiController]
[Route("api/users")]
public class UsersController(IChatRepository repo) : ControllerBase
{
    [HttpPost]
    public async Task<ActionResult<CreateUserResponse>> Create(CreateUserRequest req, CancellationToken ct)
    {
        if (string.IsNullOrWhiteSpace(req.DisplayName)) return BadRequest();
        var user = await repo.CreateUserAsync(req.DisplayName, ct);
        return Ok(new CreateUserResponse { User = user });
    }
}
